<template>
    <div class="app-container">
      <div class="header-bar">
        <a-input-search
          placeholder="可根据系统名称或者系统编码查询"
          style="width: 200px"
        />
  
        <div class="status-tabs">
          <a-button
            v-for="tab in statusTabs"
            :key="tab.value"
            :type="activeTab === tab.value ? 'primary' : 'default'"
            @click="activeTab = tab.value"
            size="middle"
          >
            {{ tab.label }}
          </a-button>
        </div>
  
        <div class="action-buttons">
          <a-button type="primary" size="middle">导入</a-button>
          <a-button size="middle">全量导出</a-button>
        </div>
      </div>
  
      <div class="system-card-list">
        <a-row :gutter="16">
          <a-col style="margin-bottom: 10px;"
            :xs="24"
            :sm="12"
            :md="8"
            :lg="6"
          >
            <a-card
              class="system-card"
              :class="{
                'new-system': '新建',
              }"
              :body-style="{ padding: '16px' }"
              hoverable
            >
              <div class="card-top-right">
               
                
              </div>
  
              <div class="card-icon">
                <component :is="PlusOutlined" :size="24" />
              </div>
  
              <div class="card-content">
                <h3 class="card-title">新建系统</h3>
                <p class="card-desc"></p>
                <p class="card-code"></p>
              </div>
            </a-card>
          </a-col>
          <a-col style="margin-bottom: 10px;"
            v-for="(system, index) in systemList"
            :key="system.procDefId || `system-${index}`"
            :xs="24"
            :sm="12"
            :md="8"
            :lg="6"
          >
            <a-card
              class="system-card"
              :class="{
                'enabled-system': '已启用',
              }"
              :body-style="{ padding: '16px' }"
              hoverable
            >
              <div class="card-top-right">
                <div class="status-tag">
                    已启用
                </div>
                <a-dropdown>
                  <a-button type="text" size="small" :icon="h(EllipsisOutlined)" />
                  <template #overlay>
                    <a-menu>
                      <a-menu-item key="edit">编辑</a-menu-item>
                      <a-menu-item key="delete">删除</a-menu-item>
                    </a-menu>
                  </template>
                </a-dropdown>
              </div>
  
              <div class="card-icon">
                <component :is="system.icon || WindowsOutlined" :size="24" />
              </div>
  
              <div class="card-content">
                <h3 class="card-title">{{ system.procName }}</h3>
                <p class="card-desc">{{  '无描述' }}</p>
                <p class="card-code">系统编码</p>
              </div>
            </a-card>
          </a-col>
        </a-row>
  
        <div v-if="systemList.length === 0" style="text-align: center; padding: 48px;">
          <a-empty description="暂无匹配的系统数据" />
        </div>
      </div>
    </div>
  </template>
  
  <script  setup lang="tsx">
  import { ref, computed, h } from 'vue';
  import {
    WindowsOutlined,
    CheckSquareOutlined,
    BuildOutlined,
    HomeOutlined,
    RocketOutlined,
    FileTextOutlined,
    PlusOutlined,
    EllipsisOutlined
  } from '@ant-design/icons-vue';
  import { getCommonFlowList } from '@/api/flow/index';
  
  
  const systemList = ref([]);
  
  const activeTab = ref('全部');
  const statusTabs = [
    { label: '全部', value: '全部' },
    { label: '已启用', value: '已启用' },
    { label: '已停用', value: '已停用' },
  ];

  const loadComData = async () => {
      const data = await getCommonFlowList();
      systemList.value = data.result?.flowList ?? [];
      console.log("systemList11",systemList.value)
  };
  loadComData();
  </script>
  
  <style scoped>
  .app-container {
    min-height: 100vh;
    background: #f5f7fa;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 0;
  }
  
  .header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: #ffffff;
    border-bottom: 1px solid #e8e8e8;
    gap: 8px;
    flex-wrap: wrap;
  }
  
  .status-tabs {
    display: flex;
    gap: 8px;
    margin: 0;
  }
  
  .action-buttons {
    display: flex;
    gap: 8px;
    margin: auto;
  }
  
  .system-card-list {
    padding: 24px;
  }
  
  .system-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative; 
    padding-bottom: 5px;
  }
  
  .system-card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08), 0 3px 6px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
  }
  
  .card-top-right {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    gap: 8px;
    z-index: 1;
  }
  
  .status-tag {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
    font-weight: 500;
  }
  
  .card-icon {
    border: 1px dashed #d9d9d9;
    color: #1890ff;
    background: rgba(24, 144, 255, 0.05);
  }
  
  .disabled-system .status-tag {
    background: #fff1f0;
    color: #ff4d4f;
    border: 1px solid #ffccc7;
  }
  
  .enabled-system .status-tag {
    background: #f0f9eb;
    color: #52c41a;
    border: 1px solid #c3e6be;
  }
  
  .card-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    margin: 0 0 16px 0;
  }

  .card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
  }
  
  .card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1f2937;
    line-height: 1.4;
    margin-top: 0;
  }
  
  .card-desc {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    line-height: 1.5;
    margin-top: 0;
  }
  
  .card-code {
    font-size: 12px;
    color: #9ca3af;
    margin: 0;
    line-height: 1.4;
    position: absolute;
    bottom: 5px;
    left: 16px;
    z-index: 1;
  }
  
  @media (max-width: 1200px) {
    .system-card-list {
      padding: 16px;
    }
  }
  
  @media (max-width: 768px) {
    .header-bar {
      padding: 12px 16px;
    }
    .status-tabs {
      order: 3;
      width: 100%;
      justify-content: flex-start;
      overflow-x: auto;
      padding-bottom: 8px;
    }
  }
  
  @media (max-width: 480px) {
    .ant-input-search {
      width: 100% !important;
    }
    .action-buttons {
      width: 100%;
      justify-content: space-between;
    }
  }
  </style>
  
  <style>
  
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  </style>